<?php
namespace Apps\BoxEdu\Model;

use Think\Model;

class EduSubjectOrderModel extends \BaseModel {

	public function load($id = "") {
		$data = BoxModel("system_order")->load($id);
		return $data;
	}

	/***********取消订单***/
	public function cancel($order_sn) {
		$data = $this->where(array('order_sn' => $order_sn))->find();
		//dump($data);exit();

		if ($data['status'] == 1) {
			$r = $this->where("order_sn='$order_sn'")->save(array('status' => 3));
		}

		return $r;
	}

	/***********订单的评论***/
	public function getComment($where, $limit = 10, $order = "id desc") {
		$topic = BoxModel("sns_topic");
		$comment = BoxModel("edu_order_topic");
		$data = $comment->get($where, $limit, $order);
		$re = array();
		foreach ($data['list'] as $one) {
			$row = $topic->load($one['topic_id']);
			$row = array_merge($row, $one);
			$row['subject'] = BoxModel("edu_subject")->where(array('subjectid' => $one['pid']))->find();
			$re[] = $row;

		}
		$data = array(
			'count' => $count,
			'list' => $re,
			'pager' => $page,
		);
		return $data;
	}

}
